package by.grsu.hdm.media;

import java.util.ArrayList;
import java.util.List;

import by.grsu.hdm.exception.BadIdException;
import by.grsu.hdm.exception.EmptyPlayListException;
import by.grsu.hdm.exception.MyExceptions;

public class MediaPlayer {
	
	private List<IHasMediaData> files = new ArrayList<IHasMediaData>();
	
	public MediaPlayer()
	{
		
	}
	
	public void addFile(IHasMediaData newFile)
	{
		files.add(newFile);
	}
	
	public String play() throws EmptyPlayListException
	{
		String temp = "";
		if(files.size() == 0)
			throw new EmptyPlayListException("List of Played Files is Empty!");
		for(IHasMediaData file : files)
		{
			temp+= "Play -> Name- " + file.getMedia().getName() + " \n" +
					" Author- " +file.getMedia().getAuthor();
		}
		return temp;
	}
	public String play(int id) throws MyExceptions
	{
		if(files.size() == 0)
			throw new EmptyPlayListException("List of Played Files is Empty!");
		if(id>=files.size()|| id< 0)
			throw new BadIdException("We haven't file with this number Id  -"+id);
		return "Play -> Name- " + files.get(id).getMedia().getName() + " \n" +
					" Author- " +files.get(id).getMedia().getAuthor();
		
	}
	public void stop()
	{
		System.out.println( "Stop Media Player");
	}
	public void pause()
	{	
		System.out.println( "pause Media Player");
	}
	
	public List<IHasMediaData> getFiles() {
		return files;
	}

	public int getCountFiles()
	{
		return files.size();
	}
	public void setFiles(List<IHasMediaData> files) {
		this.files = files;
	}
}
